package com.llmcu.filter;


import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * xxxx
 *
 * @author liuling
 * @date 2024-10-21 15:36
 */
@WebFilter(urlPatterns = "/*", filterName = "filter1")
@Slf4j
public class MyFilter implements Filter{


    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("init3333");
        log.info("init MyFilter-----------------------------");
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
        log.info("start dealing req:[{}]",httpServletRequest.getRequestURL());
        chain.doFilter(request,response);
        log.info("finish dealing req:[{}]",httpServletRequest.getRequestURL());
    }

    @Override
    public void destroy() {
        log.info("destroy myFilter-------------------------------");
    }
}
